package com.day12.study.community_demo;

public class ProductBase {
    private String name;
    private int price;
    private boolean isFull = false;

    public synchronized void put(String paraName, int paraPrice) {
        if (isFull) {
            try {
                wait();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
        this.name = paraName;
        this.price = paraPrice;
        isFull = true;
        notify();
    }

    public synchronized void get() {
        if (!isFull) {
            try {
                wait();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
        System.out.println(name + ":" + price);
        isFull = false;
        notify();
    }
}
